package cn.study.luckyapp.assembler;

import cn.study.luckyclient.dto.RecordAddCmd;
import cn.study.luckyclient.dto.data.RecordVo;
import cn.study.luckydomain.record.RecordEntity;
import cn.study.luckydomain.record.RecordStates;

import java.time.LocalDateTime;

public class RecordAssembler {
        public static RecordEntity toAddEntity(RecordAddCmd cmd) {
            RecordEntity recordEntity = new RecordEntity();
            recordEntity.setId(cmd.getId());
            recordEntity.setUserId(cmd.getUserId());
            recordEntity.setActivityId(cmd.getActivityId());
            recordEntity.setActivityName(cmd.getActivityName());
            recordEntity.setAwardId(cmd.getAwardId());
            recordEntity.setIsWinning(cmd.getIsWinning());
            recordEntity.setState(new RecordStates(cmd.getState()));
            recordEntity.setCreateTime(LocalDateTime.now());
            recordEntity.setCreator("小三");
            recordEntity.setUpdateTime(LocalDateTime.now());
            recordEntity.setUpdater("小三");

            return recordEntity;
        }

        public static RecordVo toRecordVO(RecordEntity entity) {
            RecordVo recordVO = new RecordVo();
            recordVO.setAwardName(entity.getAwardName());
            recordVO.setPrizeName(entity.getPrizeName());
            recordVO.setId(entity.getId());
            recordVO.setUserId(entity.getUserId());
            recordVO.setActivityId(entity.getActivityId());
            recordVO.setActivityName(entity.getActivityName());
            recordVO.setAwardId(entity.getAwardId());
            recordVO.setIsWinning(entity.getIsWinning());
            recordVO.setState(entity.getState().getState());
            recordVO.setCreateTime(entity.getCreateTime());
            recordVO.setCreator(entity.getCreator());
            recordVO.setUpdateTime(entity.getUpdateTime());
            recordVO.setUpdater(entity.getUpdater());
            recordVO.setPrizeType(entity.getPrizeType());

            return recordVO;
        }
}
